/**
 * Created by Administrator on 2016/11/3.
 */
(function(){
    var company={
        init:function(){
            this.area();
            this.areaTxt();
        },
        areaTxt:function(){ /*地区选择后显示地区*/
            var arr=window.location.search.split("&");
            for(var i=0,iLen=arr.length;i<iLen;i++){
                var prv=/p_id/ig.test(arr[i]);
                var are=/c_id/ig.test(arr[i]);
                if(prv){

                    $(".select_area1 a").each(function(){
                        if($(this).data("areaid")==arr[i].split("=")[1]){
                            console.log($(this).text());
                            $(".select_area1 span").text($(this).text());
                        }
                    });
                }
                if(are){
                    $(".select_area2 a").each(function(){
                        if($(this).data("areaid")==arr[i].split("=")[1]){
                            $(".select_area2 span").text($(this).text());
                        }
                    });

                }
            }
        },
        area:function(){  /*地区选择*/
            this.areaShow();
        },
        areaShow:function(){
            $(".select_area2 p").hide();
            this.areaClick($(".select_area1"));
            this.areaClick($(".select_area2"));

            $(".select_area1").on("click","a",function(){
                $(this).parent().hide();
            });

            $(".select_area2").on("click","a",function(){
                $(this).closest(".select_list").hide();
            });

            $(document).on("click",function(){
                $(".select_area1").find(".select_list").hide();
                $(".select_area2").find(".select_list").hide();
            });
        },
        areaClick:function(obj){
            obj.on("click","span",function(event){
                $(this).parent().find(".select_list").toggle().end().siblings().find(".select_list").hide();
                event.stopPropagation();
            });
        },
    };
    company.init();

    $(".company_lt").on("click",".lt_bot a",function(){
        layer.msg('功能正在完善中',{icon:1,time:1000});
        return false;
    });

})();